<script setup lang="ts">
import GravatarLink from "@gravatar/js";
import { computed } from "vue";

type GAvatarProps = {
  email: string;
  size?: number | string;
};

const { email, size = 32 } = defineProps<GAvatarProps>();

const avatarLink = computed(() => {
  const avatarLink = GravatarLink({
    email: email || "",
    size: 200,
    defaultImage: "retro",
    protocol: "https",
  });

  // 转到 cravatar.cn 源
  const newLink = new URL(avatarLink);
  newLink.host = "cravatar.cn";
  return newLink.toString();
});
</script>

<template>
  <a-avatar :src="avatarLink" :size="size"  />
</template>

<style scoped lang="less"></style>
